<!-- BEGIN PAGE HEADER-->
<?php $this->load->view('partials/breadcrumb.tpl')?>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<script type="text/javascript">
function defConfirm(url){
	if(!confirm("确定要删除吗？")){
		return false;
	}
	window.location.href = url;
	return true;
}

$(document).ready(function(){
	$("#reset").click(function(){
		$("select").val('');
		$("input[type='text']").val('');
	});
	
});
function checkExcelUploadForm(){
	var fileName = $("input[name='excel_file']").val();
	if(!$("input[name='excel_file']").val()){
		alert('请先选择exel文件');
		return false;
	}

	if(fileName.indexOf('asin') == -1){
		alert('asin的excel导入文件必需以“asin”开头命名！');
		return false;
	}
	return true;
}
</script>
<div class="row">
	<div class="col-xs-12">
		<!-- Begin: life time stats -->
		<div class="portlet">
			<?=form_open('', Array('class'=>'form-inline', 'role'=>'form'))?>
				<?=search_form_input('asin',filterValue('asin'),'商品ASIN', 'class="form-control input-medium"');?>
				<?=search_form_dropdown('creator_id',array(''=>'选择创建者...')+$allReviewAdmins,filterValue('creator_id'),'创建者', 'class="form-control input-medium"');?>
				<?=search_form_dropdown('status',array(''=>'选择状态...')+MAsin::getState(),filterValue('status'),'状态', 'class="form-control input-medium"');?>
				
				<div style="clear:both;height:15px;"></div>
				<div class="input-group input-xs">
                	<input type="text" class="form-control" name="asin_number_perpage" value="<?=filterValue('asin_number_perpage')?>" placeholder="每页显示条数">
                </div>
                <?=search_form_dropdown('asin_order_type',array(''=>'排序方式...')+MAsin::getOrderType(),filterValue('asin_order_type'),'排序', 'class="form-control input-xs"');?>
				<div class="input-group input-large date-picker input-daterange" data-date="" data-date-format="yyyy-mm-dd">
                	<input type="text" class="form-control" name="asin_create_time_begin" value="<?=filterValue('asin_create_time_begin')?>" placeholder="开始时间" autoComplete="off">
                    <span class="input-group-addon">to </span>
                    <input type="text" class="form-control" name="asin_create_time_end" value="<?=filterValue('asin_create_time_end')?>" placeholder="结束时间" autoComplete="off">
                </div>
				
				<button type="button" class="btn default" id="reset">重置条件</button>
				<button type="submit" class="btn green about_search">搜索 <i class="fa fa-search"></i></button>
			<?=form_close()?>
			<?=form_open_multipart(site_url($thisModule.$thisController.'/excelImportHandler'), Array('class'=>'form-inline', 'onSubmit'=>'return checkExcelUploadForm()','style'=>'margin-top:10px;text-align:right;'))?>
				<div class="form-group" style="margin-right: 30px;">
				<span>筛选后数量：<b style="color:#e20000;"><?=$filterCount;?></b> , 全部数量：<b style="color:#00a200;"><?=$totalCount?></b></span>
				</div>
				<div class="form-group">
					<label class="sr-only">商品ASIN</label>
					<input type="file" name="excel_file" class="form-control input-medium">
				</div>
				<button type="submit" class="btn red">导入Excel <i class="fa"></i></button>
			<?php form_close()?>
			<div class="portlet-body">
				<div class="row">
					<div class="col-xs-12">
						<div class="table-scrollable">
							<table class="table table-hover table-bordered table-striped">
								<thead>
									<tr>
										<th width="4%">ID</th>
										<th width="6%">ASIN</th>
										<th width="15%">ASIN链接</th>
										<th width="6%">找到邮箱</th>
										<th width="5%">创建者</th>
										<th width="3%">国家</th>
										<th width="3%">状态</th>
										<th width="10%">创建时间</th>
										<th width="10%">操作</th>
									</tr>
								</thead>
								<tbody>
								<?php foreach($list as $v){?>
									<tr>
										<td><?=$v->id?></td>
										<td><?=htmlspecialchars($v->asin)?></td>
										<td>
											<?php if($v->country == 'US'):?>
												<?='https://www.amazon.com/dp/'.strtoupper($v->asin)?>
											<?php elseif($v->country == 'UK'):?>
												<?='https://www.amazon.co.uk/dp/'.strtoupper($v->asin)?>
											<?php else:?>
												<?='https://www.amazon.'.strtolower($v->country).'/dp/'.strtoupper($v->asin)?>
											<?php endif;?>
										</td>
										<td><?=$v->email_num?> 个，<?php if($v->email_num>0):?><a href="<?=site_url('/emails/email/index/'.$v->asin)?>">查看</a><?php else:?>没有<?php endif;?></td>
										<td><?=$allReviewAdmins[$v->creator_id];?></td>
										<td><?=IOSS_StaticConfig::getCountryInfo(strtoupper($v->country))?></td>
										<td><?=MAsin::getState($v->status);?></td>
										<td><?=date('Y-m-d H:i:s',$v->create_time)?></td>
										<td>
											<a href="<?=site_url($thisModule.$thisController.'/edit/'.$v->id)?>" class="about_edit btn <?=$p->edit?'':'disabled' ?>" ><i class="fa fa-edit"></i> 编辑</a>
											<?php if($p->delete){?>
											<a class="black" href="javascript:void(defConfirm('<?=site_url($thisModule.$thisController.'/delete/'.$v->id.'/'.$v->update_time) ?>'));"><i class="fa fa-trash-o"></i> <?=l('delete')?></a>
											<?php }?>
										</td>
									</tr>
								<?php }?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12 text-right">
						<?=$pagination?>
					</div>
				</div>
			</div>
		</div>
		<!-- End: life time stats -->
	</div>
</div>
<!-- END PAGE CONTENT-->